/**************************************************************
                                              
                    
      Master do file for Ghosh (2024):
      Religious Divisions and Production Technology --
      Experimental Evidence from India
	  
	  This do-file prepares data and reproduces all figures
	  and tables in the paper.


**************************************************************/



clear all

*Install all packages that this project requires (switch local to 1):
* Might need to add "replace" to get the most updated versions in some cases
global install_package 0
if $install_package == 1 {
ssc install strip
ssc install dmout
ssc install blindschemes
ssc install estout
ssc install boottest
ssc install ritest
ssc install icw_index
ssc install chartab
ssc install scheme-burd
ssc install parmest
ssc install reghdfe
ssc install ftools
ssc install coefplot
ssc install binscatter
net install binsreg, from(https://raw.githubusercontent.com/nppackages/binsreg/master/stata) replace
}

* Root folder 
* ---------------------
global projectfolder "/Users/ag734/Desktop/JPE_Replication" 
                      /*insert working directory to the project folder here*/


* Project folder globals
* ---------------------
global Code         "$projectfolder/Code"
global Prep         "$Code/Prep"
global Analysis     "$Code/Analysis"

global Data         "$projectfolder/Data"

global Output       "$projectfolder/Output"

* Switches
* ---------------------
global Preparation     1        // Set to 1 to run all preparation files
global Analyses        1        // Set to 1 to run all analysis files

// Preparation Files (Do-files 05 and 06 do not use restricted data)
if $Preparation == 1 {
    do "$Prep/00 dependency summary stats.do"   // This is run again for Analysis since it produces figures and tables.       
    do "$Prep/01 prep balance.do"                     
    do "$Prep/02 section_aggregates.do"
    do "$Prep/03 worker_interactions_clean.do"
    do "$Prep/04 worker_attitudes_clean.do"
    do "$Prep/05 individual productivity clean.do"
    do "$Prep/06 beliefs_clean.do"
}

// Analysis Files (Do-files 08, 09 and 10 do not use restricted data)
if $Analyses == 1 {
    do "$Analysis/01 dependency summary stats.do"      // Table 1, Table B.2, Figure 3
    do "$Analysis/02 balance_tables.do"                // Table A.4, Table A.3, Table A.5, Table A.8, Table B.12, Table A.7, Table A.6, Table B.1, Table B.14, Table A.9, Table A.1, Table A.2, Figure C.9
    do "$Analysis/03 line_level_regressions.do"        // Table 2, Table B.3, Table B.4, Figure 7, Table B.17
    do "$Analysis/04 linesection_level_regressions.do" // Table 3, Table B.7, Table B.8, Table B.5, Table B.13. Table B.10, Table 6, Table B.18, Table B.19, Figure C.3, Table B.6, Figure C.4, Figure C.5, Table B.24, Table B.23, Table B.9.
    do "$Analysis/05 worker_teammate_regressions.do"   // Table 4, Table B.11, Table B.15, Table B.20
    do "$Analysis/06 worker_level_regressions.do"      // Table 5, Table B.16, Table B.21
    do "$Analysis/07 allocation_comparisons.do"        // Figure 2
    do "$Analysis/08 belief_analysis.do"               // Figure C.7
    do "$Analysis/09 indiv_produc_analysis.do"         // Figure C.6
	do "$Analysis/10 firm_manager_survey.do"           // Figure C.14, Figure C.15, Figure C.16
    do "$Analysis/11 output_ratings_correlation.do"    // Figure C.10, Figure C.11, Figure C.12
    do "$Analysis/12 survey_quality.do"                // Figure C.13
}


